;;;Dynamic Zoom/Pan trick.  Best for simpler drawings.
;;;
;;;	Modified from a tip in Cadylst or Cadence (don't remember which).
;;;	Modification requires UINT.LSP and UKWORD.LSP (see UUTILS.LSP)
;;;
;;;
(DEFUN dp_error (msg /)
  (SETVAR "osmode" old_osmode)
  (SETVAR "cursorsize" cursorpct)
  (SETQ *error* (IF old_error
                  old_error
                  NIL
                ) ;_ end of IF
  ) ;_ end of SETQ
  (SETQ ent_10x NIL
        ent_10y NIL
        ent_10z NIL
        ent_11x NIL
        ent_11y NIL
        ent_11z NIL
        1is_grd NIL
        1is_top NIL
        1is_inv NIL
        2is_grd NIL
        2is_top NIL
        2is_inv NIL
  ) ;_ end of SETQ
  (PRINC "\n")
  (PRINC msg)
  (PRINC)
) ;_ end of defun
(defun c:dynpan ( / panpt input pt1 pt2 pt3 pt4 zin zout)
(SETQ old_error *error*)
(SETQ *error* dp_error)
(setq old_osmode (getvar"osmode"))
(setvar "osmode" 0)
(setq cursorpct (getvar"cursorsize"))
(setvar "cursorsize" 5)
(if uint nil (load "uint" "\nFile UINT.LSP not loaded! "))
(if ukword nil (load "ukword" "\nFile UKWORD.LSP not loaded! "))
(setq whip (ukword 1 "In Out Stay" "\nPan and Zoom-In/Out/Stay" (if whip whip "Stay")))
(if
  (or
    (eq whip "In")
    (eq whip "Out")
  )
    (setq zspd (uint 0 "" "\nZoom Speed (Slow=1, Fast=9)" (if zspd zspd 1))
          zin (strcat(rtos(+ 1.0(/ zspd 100.000)))"x")
          zout (strcat(rtos(- 1.0(/ zspd 100.000)))"x"))
)
(setq fctr (if (eq whip "Stay") "Pan" (ukword 1 "Center Pan" "Zoom by Center or Pan?" (if fctr fctr "Pan"))))
(if (eq fctr "Pan")
  (setq fctr nil)
)
  (IF (EQ (SUBSTR (GETVAR "ACADVER") 1 2) "15")
    (PROGN
      (setq old_ucsview (getvar"ucsview"))
      (setvar "ucsview" 0)
    )
  )
  (IF (=(ATOI(SUBSTR(GETVAR "ACADVER")1 2))15)
    (COMMAND "-VIEW" "S" "PRE-DP" "")
    (COMMAND "VIEW" "S" "PRE-DP")
  )
  (while
    (and
      (setq INPUT (grread T 2 2))
        (= (car INPUT) 5)
    )
    (if fctr
      (setq PANPT (getvar "viewctr"))
      (if PANPT
        (setq PANPT
                (polar
                  PANPT
                  (angle PANPT (cadr INPUT))
                  (/
                    (getvar"viewsize")
;                    (distance (getvar"VSMAX")(getvar"VSMIN"))
                    (/
;                      500
                      (*(getvar"viewsize")5)
                      (max(distance (cadr INPUT) PANPT)0.005)
                    )
                  )
                )
        )
        (setq PANPT (cadr INPUT))
      );if
    );
    (if (>(distance PANPT(cadr INPUT))(*(getvar"viewsize")0.005))
      (command ".zoom" "c" PANPT "")
    )
    (cond
      ((eq whip "In")
        (command ".zoom" zin))
;        (princ(strcat"\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010Pan/Zoom-In " (rtos(car PANPT))","(rtos(cadr PANPT))))
      ((eq whip "Out")
        (command ".zoom" zout))
;        (princ(strcat"\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010Pan/Zoom-Out " (rtos(car PANPT))","(rtos(cadr PANPT))))
;      ((eq whip "Stay")
;        (princ(strcat"\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010\010Panning..."
;        (rtos(car PANPT))","(rtos(cadr PANPT)))))
    )
  )
  (setvar "osmode" old_osmode)
  (setvar "cursorsize" cursorpct)
  (PRINC)
;  (C:GPDGN)
)
(DEFUN C:PREDP ()
  (IF (EQ(SUBSTR(GETVAR "ACADVER")1 2)"15")
    (COMMAND "-VIEW" "RESTORE" "PRE-DP")
    (COMMAND "VIEW" "RESTORE" "PRE-DP")
  )
  (setvar "ucsview" old_ucsview)
)
(PRINC)
